{smcl}
{txt}{sf}{ul off}{.-}
      name:  {res}<unnamed>
       {txt}log:  {res}E:\Github\Bolivia\00_replication_files\log-files/3_Table_F1.smcl
  {txt}log type:  {res}smcl
 {txt}opened on:  {res}25 Jan 2022, 22:40:04
{txt}
{com}. 
. timer on 2
{txt}
{com}. 
. * Loading myround, which is a program written by us to round numbers
. cap program drop myround
{txt}
{com}. include "codes/auxiliary_programs/myround.ado"
{txt}
{com}. capture program drop myround
{txt}
{com}. program define myround, eclass
{txt}  1{com}.         syntax varlist (min=1 max=1 numeric), decimals(numlist min=1 max=1)
{txt}  2{com}.         
.         tokenize `varlist'
{txt}  3{com}.         local var "`1'"
{txt}  4{com}.         
.         tostring `var', gen(temp_str) force
{txt}  5{com}. 
.         replace temp_str="0.00000" if strpos(temp_str,"e-")>0 & substr(temp_str,1,1)!="-"
{txt}  6{com}.         replace temp_str="-0.00000" if strpos(temp_str,"e-")>0 & substr(temp_str,1,1)=="-"
{txt}  7{com}.         
.         split temp_str, p(".")
{txt}  8{com}.         local nv=r(nvars)
{txt}  9{com}.         if `nv'>1 {c -(}
{txt} 10{com}.                 replace temp_str1="0" if temp_str1==""
{txt} 11{com}.                 replace temp_str1="-0" if temp_str1=="-"
{txt} 12{com}.                 
.                 local flag=0
{txt} 13{com}.                 while `flag'==0 {c -(}
{txt} 14{com}.                         cap drop length2
{txt} 15{com}.                         gen length2=length(temp_str2)
{txt} 16{com}.                         replace temp_str2=temp_str2+"0" if length2<`decimals'+1
{txt} 17{com}.                         
.                         drop length2
{txt} 18{com}.                         gen length2=length(temp_str2)
{txt} 19{com}.                         quietly sum length2
{txt} 20{com}.                         local min=r(min)-1
{txt} 21{com}.                         if `min'>=`decimals' {c -(}
{txt} 22{com}.                                 local flag=1
{txt} 23{com}.                         {c )-}
{txt} 24{com}.                 {c )-}
{txt} 25{com}.                 cap drop length2
{txt} 26{com}.                 
.                 gen var_first_tpositions=substr(temp_str2,1,`decimals')
{txt} 27{com}.                 local t=`decimals'+1
{txt} 28{com}.                 gen var_tthpos=substr(temp_str2,`t',1)
{txt} 29{com}.                 destring var_first_tpositions var_tthpos, force replace
{txt} 30{com}.                 replace var_first_tpositions=var_first_tpositions+1 if var_tthpos>=5
{txt} 31{com}.                 replace var_first_tpositions=var_first_tpositions+0 if var_tthpos<5
{txt} 32{com}.                 
.                 tostring var_first_tpositions, force replace
{txt} 33{com}.                 local flag=0
{txt} 34{com}.                 while `flag'==0 {c -(}
{txt} 35{com}.                         cap drop length1
{txt} 36{com}.                         gen length1=length(var_first_tpositions)
{txt} 37{com}.                         replace var_first_tpositions="0"+var_first_tpositions if length1<`decimals'
{txt} 38{com}.                         
.                         cap drop length1
{txt} 39{com}.                         gen length1=length(var_first_tpositions)
{txt} 40{com}.                         quietly sum length1
{txt} 41{com}.                         local min=r(min)
{txt} 42{com}.                         if `min'>=`decimals' {c -(}
{txt} 43{com}.                                 local flag=1
{txt} 44{com}.                         {c )-}
{txt} 45{com}.                 {c )-}
{txt} 46{com}.                 cap drop length1
{txt} 47{com}.                 
.                 rename `var' vv
{txt} 48{com}.                 gen `var'=temp_str1+"."+var_first_tpositions
{txt} 49{com}.                 drop temp_str* var_first_tpositions var_tthpos
{txt} 50{com}.                 replace `var'="" if vv==.
{txt} 51{com}.                 drop vv
{txt} 52{com}.         {c )-}
{txt} 53{com}.         else {c -(}
{txt} 54{com}.                 tostring `var', force replace
{txt} 55{com}.                 drop temp*
{txt} 56{com}.         {c )-}
{txt} 57{com}. end
{txt}
{com}. {txt}
{com}. 
. *-----------*
. * Table F.1 *
. *-----------*
.         use "data/outputs/RD_sortings.dta", clear
{txt}
{com}. 
.         foreach x of varlist R01-R22 {c -(}
{txt}  2{com}.                 quietly sum `x', detail
{txt}  3{com}.                 local mean_`x' = r(mean)
{txt}  4{com}.                 local median_`x' = r(p50)
{txt}  5{com}.         {c )-}
{txt}
{com}. 
.         count
  {res}1,000
{txt}
{com}.         local num_sims = r(N)
{txt}
{com}. 
.         clear
{txt}
{com}.         set obs 3
{txt}{p}
number of observations (_N)  was 0,
now 3
{p_end}

{com}. 
.         foreach k of numlist 1 3 {c -(}
{txt}  2{com}.                 local kk = `k' - 1
{txt}  3{com}. 
.                 cap gen pval_mean = .
{txt}  4{com}.                 replace pval_mean = `mean_R`kk'2' if _n == `k'
{txt}  5{com}. 
.                 cap gen pval_median = .
{txt}  6{com}.                 replace pval_median = `median_R`kk'2' if _n == `k'
{txt}  7{com}. 
.                 cap gen estim_mean = .
{txt}  8{com}.                 replace estim_mean = `mean_R`kk'1' if _n == `k'
{txt}  9{com}. 
.                 cap gen estim_median = .
{txt} 10{com}.                 replace estim_median = `median_R`kk'1' if _n == `k'
{txt} 11{com}.         {c )-}
{txt}(1 real change made)
(1 real change made)
(1 real change made)
(1 real change made)
(1 real change made)
(1 real change made)
(1 real change made)
(1 real change made)

{com}. 
.         drop if _n == 2
{txt}(1 observation deleted)

{com}. 
.         foreach x of varlist pval* estim* {c -(}
{txt}  2{com}.                 myround `x', decimals(3)
{txt}  3{com}.         {c )-}
{txt}temp_str generated as {res:str11}
temp_str was forced to string; some loss of information
(0 real changes made)
(0 real changes made)
{res}variables created as string: 
{txt}{col 1}temp_str1{col 12}temp_str2
(2 real changes made)
(0 real changes made)
(0 real changes made)
var_first_tpositions: all characters numeric; {res}replaced {txt}as {res}int
{txt}var_tthpos: all characters numeric; {res}replaced {txt}as {res}byte
{txt}(0 real changes made)
(0 real changes made)
var_first_tpositions was {res:int} now {res:str3}
(0 real changes made)
{res}{txt}(0 real changes made)
temp_str generated as {res:str11}
temp_str was forced to string; some loss of information
(0 real changes made)
(0 real changes made)
{res}variables created as string: 
{txt}{col 1}temp_str1{col 12}temp_str2
(2 real changes made)
(0 real changes made)
(0 real changes made)
var_first_tpositions: all characters numeric; {res}replaced {txt}as {res}int
{txt}var_tthpos: all characters numeric; {res}replaced {txt}as {res}byte
{txt}(1 real change made)
(0 real changes made)
var_first_tpositions was {res:int} now {res:str3}
(0 real changes made)
{res}{txt}(0 real changes made)
temp_str generated as {res:str12}
temp_str was forced to string; some loss of information
(0 real changes made)
(0 real changes made)
{res}variables created as string: 
{txt}{col 1}temp_str1{col 12}temp_str2
(1 real change made)
variable {bf}temp_str1{sf} was {bf}{res}str1{sf}{txt} now {bf}{res}str2{sf}
{txt}(1 real change made)
(0 real changes made)
var_first_tpositions: all characters numeric; {res}replaced {txt}as {res}byte
{txt}var_tthpos: all characters numeric; {res}replaced {txt}as {res}byte
{txt}(0 real changes made)
(0 real changes made)
var_first_tpositions was {res:byte} now {res:str2}
variable {bf}var_first_tpositions{sf} was {bf}{res}str2{sf}{txt} now {bf}{res}str3{sf}
{txt}(2 real changes made)
{res}{txt}(0 real changes made)
temp_str generated as {res:str12}
temp_str was forced to string; some loss of information
(0 real changes made)
(0 real changes made)
{res}variables created as string: 
{txt}{col 1}temp_str1{col 12}temp_str2
(1 real change made)
variable {bf}temp_str1{sf} was {bf}{res}str1{sf}{txt} now {bf}{res}str2{sf}
{txt}(1 real change made)
(0 real changes made)
var_first_tpositions: all characters numeric; {res}replaced {txt}as {res}byte
{txt}var_tthpos: all characters numeric; {res}replaced {txt}as {res}byte
{txt}(0 real changes made)
(0 real changes made)
var_first_tpositions was {res:byte} now {res:str2}
variable {bf}var_first_tpositions{sf} was {bf}{res}str2{sf}{txt} now {bf}{res}str3{sf}
{txt}(2 real changes made)
{res}{txt}(0 real changes made)

{com}. 
.         preserve
{txt}
{com}.                 use "data/outputs/computo_verificadortrepdate_nomissings.dta", clear
{txt}
{com}. 
.                 sum pcs_so if trep_date_verificador >= tc(20oct2019 19:40:57)

{txt}    Variable {c |}        Obs        Mean    Std. Dev.       Min        Max
{hline 13}{c +}{hline 57}
{space 6}pcs_so {c |}{res}      3,612    .9451156    .0322034   .8886026          1
{txt}
{com}.                 local cutoff = r(min)
{txt}
{com}.         restore
{txt}
{com}. 
.         gen N_sims = "`num_sims'"
{txt}
{com}.         gen cutoff = "`cutoff'" if _n == 1
{txt}(1 missing value generated)

{com}.         replace cutoff = "0.950" if _n ==2
{txt}(1 real change made)

{com}.         destring cutoff, replace
{txt}cutoff: all characters numeric; {res}replaced {txt}as {res}double
{txt}
{com}.         myround cutoff, decimals(3)
{txt}temp_str generated as {res:str11}
temp_str was forced to string; some loss of information
(0 real changes made)
(0 real changes made)
{res}variables created as string: 
{txt}{col 1}temp_str1{col 12}temp_str2
(2 real changes made)
(0 real changes made)
(1 real change made)
(1 real change made)
var_first_tpositions: all characters numeric; {res}replaced {txt}as {res}int
{txt}var_tthpos: all characters numeric; {res}replaced {txt}as {res}byte
{txt}(1 real change made)
(0 real changes made)
var_first_tpositions was {res:int} now {res:str3}
(0 real changes made)
{res}{txt}(0 real changes made)

{com}. 
.         gen date = "10/20/2019 19:40:57" if _n == 1
{txt}(1 missing value generated)

{com}.         replace date = "10/20/2019 20:03:59" if _n == 2
{txt}(1 real change made)

{com}. 
.         replace N_sims="1,000" if N_sims=="1000"
{txt}variable {bf}N_sims{sf} was {bf}{res}str4{sf}{txt} now {bf}{res}str5{sf}
{txt}(2 real changes made)

{com}. 
.         gen t=_n*(-1)
{txt}
{com}.         sort t
{txt}
{com}.         drop t
{txt}
{com}. 
.         egen c = concat(cutoff date pval_mean pval_median ///
>                 estim_mean estim_median N_sims), punct(" & ")
{txt}
{com}.         keep c
{txt}
{com}.         replace c = c + " \\"
{txt}(2 real changes made)

{com}. 
.         outsheet using "outputs/generated/Table_F1.tex", replace nonames ///
>                 noquote nolabel
{txt}(note: file outputs/generated/Table_F1.tex not found)

{com}. 
. *------------------------------------------------------------------------------*
. timer off 2
{txt}
{com}. timer list 2
{res}   2:      0.03 /        1 =       0.0340
{txt}
{com}. 
. log close
      {txt}name:  {res}<unnamed>
       {txt}log:  {res}E:\Github\Bolivia\00_replication_files\log-files/3_Table_F1.smcl
  {txt}log type:  {res}smcl
 {txt}closed on:  {res}25 Jan 2022, 22:40:04
{txt}{.-}
{smcl}
{txt}{sf}{ul off}